public class Test2 {        //逻辑控制完+方法
    public static void main(String[] args) {            //打印一组都是整型的数据
        print(3, 4);
        print(3, 4, 6);
        print(3, 4, 6, 8, 2);
        print(3, 4, 6, 8, 2, 7, 5, 1);

        int[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};  //数组
        print(array);
    }

    public static void print(int a, int b) {
        System.out.println(a + " " + b);
    }

    public static void print(int a, int b, int c) {
        System.out.println(a + " " + b + " " + c);
    }

    public static void print(int... k) {        //可变参数编程
        for (int i = 0; i < k.length; i++) {
            System.out.print(k[i] + " ");
        }
        System.out.println();
    }

    public static void main2(String[] args) {    //求2个整数的最大值 求3个整数的最大值 构成方法的重载
        maxNum(4, 8);
        maxNum(5, 3, 1);                //方法重载：方法名必须相同，参数列表必须不同（类型、次序、个数）
    }

    public static int maxNum(int a, int b) {
        return a > b ? a : b;
    }

    public static int maxNum(int a, int b, int c) {
        int tmp = maxNum(a, b);
        return maxNum(tmp, c);
    }

    public static void main1(String[] args) {       //未使用方法重载时
        int a = 5;
        int b = 6;
        System.out.println(addInt(a, b));

        double d1 = 22.5;
        double d2 = 27.2;
        System.out.println(addDouble(d1, d2));
    }

    public static int addInt(int a, int b) {
        return a + b;
    }

    public static double addDouble(double a, double b) {
        return a + b;
    }

}
